import numpy as np
import scipy.integrate as integrate

# 定义函数计算离散型随机变量的数学期望
def discrete_variable(variable,probability):
    """
    计算离散型随机变量
    :param variable:随机变量
    :param probability: 随机变量对应的概率
    :return: 离散型随机变量的数学期望
    """
    if len(variable) != len(probability):
        raise ValueError("variable和probability的长度必须相同")
    #